<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head><base href="<%=basePath%>">
       <link href=" themes/css/ui.common.css" rel="stylesheet" type="text/css" />
    <link href=" themes/css/ui.child.css" rel="stylesheet" type="text/css" />
    <link href=" themes/css/ui.tips.css" rel="stylesheet" type="text/css" />
    <link href=" style/jquery_ui/jquery-ui-1.8.custom.css" rel="stylesheet" type="text/css" />
    <link id="skin_css" type="text/css" rel="stylesheet" href="themes/css/ui.c.blue.css" />
    <link rel="stylesheet" type="text/css" href="themes/default/pagination.css" />
    <link href="themes/css/ui.selector.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.8.custom.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery.json-2.2.min.js" type="text/javascript"></script>
    <script src="Scripts/ui.tips.js" type="text/javascript"></script>
    <script src="Scripts/ui.default.js " type="text/javascript" charset="UTF-8"></script>
    <script src="Scripts/ui.admincp.js" type="text/javascript" charset="UTF-8"></script>
    <script src="Scripts/ui.objectSelector.js" type="text/javascript"></script>
    <script type="text/javascript" src="Scripts/ui.dialogFormHelper.js"></script>
    <style type="text/css">
        .ui-state-default, .text-close-icon, .lm_ca, .groupclose
        {
            cursor: hand;
        }
        .ui-state-default
        {
            
        }
        #sortable .ui-state-default{
        	height: 28px; 
        	
        }
    </style>
    <script type="text/javascript" src="../../Scripts/ui.dialogFormHelper.js"></script>
    <script type="text/javascript">
        $(function () {

            $("#dialog").dialog("destroy");
            $("#dialog-form").dialog({
                autoOpen: false,
                height: 530,
                width: 767,
                modal: true,

                close: function () {
                    //allFields.val('').removeClass('ui-state-error');
                }
            });

            $('#addGoodsButton').click(function () {
        
                $("#dialog-form").dialog({ 'title': "添加 审批计划" });
                clearInputControlValue("#dialog-form .ui-mainTab");
                $('#dialog-form').dialog('open');
            });
            registeTabToggle("#addGoodsCategoryButton", "#cancelAddGoodsCategoryButton");
            //注册功能按钮事件..
            registeRowFuncButton();
			switcher();
	
        });
        
        function toEditHandler(e) {
            var columns = e.data;

            $("#dialog-form").dialog({ 'title': "编辑 计划信息" });
            $("#txt_planOrders").val($(columns[1]).text());
             
            alert($(columns[2]).text());
            $("#drl_planType").val($(columns[2]).text());
            $("#txt_postId").val($(columns[3]).text());

            $("#goodsId").val(e.entityId);
            $('#dialog-form').dialog('open');

        }
    </script>
    <script type="text/javascript">
        $(function () {
            $(".ui-state-default ").live("mouseover", function () {
                $(this).find(".text-close-icon").attr("src", "themes/icons/close-red.png");
            }).live("mouseout", function () {
                $(this).find(".text-close-icon").attr("src", "themes/icons/close-gray.png");
            });
          $(".text-close-icon").live("click",function(){
          		removeItem($(this));
          }); 
  

            $("#sortable").disableSelection();
            getAllSelected();
          
            $("#sectionSelectArea").objectSelector({  
                moveItemHandler: moveItemHandler,
                removeBackAllHandler:function (groupKey){ 
                	$(".text-close-icon").click();
                }
            });
            $("#sortable").sortable({
                placeholder: 'ui-state-highlight'
            });
        });
        
        function removeItem(sender){ 
                var _id = sender.parent().attr("sectionId");
                var name = sender.parent().text();
                sender.parent().remove();
                $("#groupOne").append(subGroupBuilder({ sectionId: _id, sectionName: name }));
                $.fn.objectSelector.countReceiverReduce("#sectionSelectArea");
         
        }
        
        function subGroupBuilder(item) {
            var result = '<div class="groupItem"><a class="lm_addr" key="g1" href="javascript:void(0)">' +
            '<div class="arguementBar" key="g1" entityId="' + item.sectionId + '" itemindex="0" title="'+item.sectionName+'">'
        + item.sectionName + ' <span class="details Tips3"> </span></div></a></div>';

            return result;
        }
        function getAllSelected() {

            $("#btnCloseSelector").click(function () {

                var checkPlanOrdersIds = "";
				var checkPlanId = "";
                $(".text-display").each(function (i) {
                    checkPlanOrdersIds += $(this).attr("sectionId") + ",";
                }); 
				checkPlanOrdersIds = checkPlanOrdersIds.substring(0, checkPlanOrdersIds.length - 1);
				var postId=$("#postSelector").val();
				var categoryId=$("#cateId").val();
               location="checkPlan.action?planOrders="+checkPlanOrdersIds+"&postId="+postId+"&categoryId="+categoryId;
            });
        } 

        function moveItemHandler(e) {
            var sectionId = $(e).find(".arguementBar").attr("entityId");
            var sectionName = $(e).text();
            $("#sortable").append("<li class=\"ui-state-default text-display\" style='text-align:right;' entityId=\"" + sectionId + "\" sectionId=\"" + sectionId + "\">" + "<span style='float:left;'>"
          + sectionName + "</span>" + '<img alt="Remove" src="themes/icons/close-gray.png" class="text-close-icon" height="10px" width="10px" title="移除" />'
+ "</li>");
        }
        
          function switcher() {
				$("#sectionSelector").change( function() {
					var sectionId = $(this).val();
					$.post("move!queryPostBySection.action", {
						"sectionId" :sectionId
					}, function(data) {
						//对应的物资信息添加到select中
						$("#postSelector").html( data);
						});
					},

					"html");
			}
    </script>
    <SCRIPT type="text/javascript">
			var searching = false;
				$(function(){
					$("#link_page_prev,#link_page_next").click(function(){
			    		var currentPage = $(this).attr("currentPage");
			    	 
			    		goToPage(currentPage);
			    	}); 
			    	
			    	$("#searchButton").click(function(){
						searching=true;
			    		goToPage(1);
			    	});
			    	
			    	initSearch();
			    	registeRowFuncButton();
				});
				
				function initSearch()
				{
				    $("#txt_noticeTitle").val();
				}
			 
				function goToPage(currentPage)
				{
				    var title = $("#txt_noticeTitle").val();
				  
				     
					location.href = "checkPlan!load.action?currpage="+currentPage;
				}
				</SCRIPT>
</head>
<body>
    <div class="PageChild_Where">
        <table style="height: 60px;" border="0" cellpadding="0" cellspacing="0">
            <tr><td class="mtd">类型名称:<input name="txt_Tile" type="text" maxlength="100" id="add" style="width: 200px;" /> <input type="submit" name="btn_Serach" value="搜索" id="btn_Serach" class="o-btn"/>
                </td>
            </tr>
            <tr>
                <td>
                   <span id="lbl_list_count">共搜索到 <b>${count }</b> 条符合条件的记录。</span>
                    <input type="button" id="addGoodsButton" class="ui-button" value="添加新审批计划" />
                </td>
            </tr>
        </table>
    </div>
    <div class="PageChild_List">
        <table width="100%" border="0" cellspacing="0" style="text-align: left">
            <tbody class="PageChild_List_head">
                <tr>
                    <td width="16">
                        <img src="themes/images/default/icons/pcde_314.png" width="16" height="16" />
                    </td>
                    <td>
                        审批计划序列
                    </td>
                    <td>
                        审批类型
                    </td>
                    <td>
                        职位序号
                    </td>
                    <td>
                        状态
                    </td>
      
                    <td class="td_width40">
                        删除
                    </td>
                </tr>
            </tbody>
            <tbody class="PageChild_List_main" style="text-align: left">
                <s:iterator value="planList" var="item">
					 
						<tr class='td_no_bord'>
							<td class="td_width25">
								<span title="24"><input id="Chk_Num" type="checkbox"
										name="ReptShow$ctl01$Chk_Num" /> </span>
							</td>
						
							<td>
								<span>
									${item.planOrders}</span>&nbsp;
							</td>
							<td>
								<span>${item.checkPlanCategory.categoryName} </span>&nbsp;
							</td>
							<td>
								<span> ${item.postInfo.postName} </span>&nbsp;
							</td>
							<td>
								<span>
									${item.states} </span>&nbsp;
							</td>
							
						
							<td>
								<a href="javascript:;"
									onclick='location="checkPlan!delete.action?planId=${item.planId}";'><img
										src="themes/icons/delete.png" /> </a>
							</td>
						</tr>
					</s:iterator> 
            </tbody>
        </table>
    </div>
    <!--分页导航开始-->
    <div id="divTopPageNavi" class="list_r_title_text3">
        <s:if test="currpage<=1">
				<span class='list_r_title_text3a'> <img
						src="<%=request.getContextPath()%>/themes/images/default/page_up_gray.gif"></img>
				</span>

			</s:if>
        <s:else>
				<span class='list_r_title_text3a'> <a name="link_page_prev"
					id="link_page_prev" href="javascript:void(0);"
					currentPage="${currpage-1}"> <img
							src="<%=request.getContextPath()%>/themes/images/default/page_up.gif"></img>
				</a> </span>
			</s:else>
        <span class='list_r_title_text3b'>第${currpage }页/共${totalpage }页 </span>
        <s:if test="currpage>=totalpage">
				<span class='list_r_title_text3a'> <img
						src="<%=request.getContextPath()%>/themes/images/default/page_down_gray.gif"></img>
				</span>
			</s:if>
        <s:else>
				<span class='list_r_title_text3a'> <a name="link_page_next"
					id="link_page_next" href="javascript:void(0);"
					currentPage="${currpage+1 }"> <img
							src="<%=request.getContextPath()%>/themes/images/default/page_down.gif"></img>
				</a> </span>
			</s:else>
        <span id="goToPageTextArea">
            <input type="text" class="easyui-numberbox" id="goPageNum" max="${totalpage}" min="1" />
            <input type="button" id="turnToPageButton" value="GO" /></span>
    </div>
    <!--分页导航结束-->
</body>
<!-- 弹出层标签 -->
<div id="dialog-form" style="display: none;" title="添加新审批计划">
    <div class="ui-mainTab">
        <div>
            <input type="text" id="planId" class="hiddenObject" />
            <table width="100%" class="tb tb2">
                <tbody>
                    <tr>
                        <td class="mtd">
                            审批类型:
                        </td>
                        <td>
                           <s:select id="cateId" theme="simple" list="categoryList" listKey="categoryId" listValue="categoryName"  headerKey="-1" headerValue="---全部---" value="categoryId"></s:select>
                            <input type="button" id="addGoodsCategoryButton" value="添加" class="o-btn">
                        </td>
                        <td width="20">
                        </td>
                    </tr>
                </tbody>
                <tr>
                    <td class="mtd">
                        审批序列:
                    </td>
                    <td>
                     <input class="control hiddenObject" value="" id="txt_planOrders" />
                        <input class="control hiddenObject" value="" id="txt_planId" />
                        <table id="sectionSelectArea" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td valign="top">
                                    <span>选择部门:</span>
                                    <div class="Box leftContainer" id="add_address_Left" style="overflow-y: auto; height: 320px;
                                        width: ">
                                        <div class="lm_sbar hiddenObject">
                                            <input type="button" class="lm_sopen" style="" id="btn_UserSearch" />
                                            <div>
                                                <input type="text" id="txt_SearchText" style="height: 19px;" value="查找人员..." class="txt" />
                                            </div>
                                        </div>
                                        <div id="lb_SearchTips" style="display: none">
                                            查找到以下结果:
                                            <div id="lm_ifNullTips">
                                            </div>
                                        </div>
                                        <div class="lm_panel hiddenObject" id="lm_SB" style="">
                                        </div>
                                        <div class="lm_panel" id="lm_ListB">
                                            <div class="groupclose" key="g1" entityid="1" open="false" hasload="true" style="font-weight: bolder;">
                                                <div style="padding: 2px 0pt 1px; height:auto; background: none repeat scroll 0% 0% rgb(255, 255, 255);
                                                    color: black;" onmouseout="this.style.background='#fff'" onmouseover="this.style.background='#ffeec2'"
                                                    class="">
                                                    <span class="Tips3 lm_helper">全部添加</span>
                                                    <div class="lm_ca" title="部门列表">
                                                        <input type="button" class="lm_ico" />
                                                        部门列表<span class="Tips3 groupItemCountTips">${sectionListSize}</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="groupOne" class="groupsub" key="g1">
                                                <s:iterator value="sectionList" var="item"> 
                            <div class="groupItem"><a class="lm_addr" key="g1" href="javascript:void(0)">
            <div class="arguementBar" key="g1" entityId="${item.sectionId }" itemindex="0" title="${item.sectionName}">
       ${item.sectionName}  <span class="details Tips3"> </span></div></a></div>
                            </s:iterator>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td align="center" style="padding: 5px;">
                                    <img alt="" src="style/arrow_left.gif" />
                                </td>
                                <td valign="top">
                                    <span>已选择(<span id="count_Receiver" class="receiverCounter">0</span>)</span>
                                    <div id="add_address" style="overflow-y: auto; height: 320px; padding-left: 3px;"
                                        class="Box rightContainer">
                                        <ul id="sortable">
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td>
                    </td>
                </tr>
               <tr>
                   <td class="mtd">
					&nbsp;部门:&nbsp;
				 </td>
				 <td>
					<s:select list="sectionList" listKey="sectionId" listValue="sectionName" headerKey="" headerValue="-请选择-" id="sectionSelector" name="sectionId" theme="simple" cssClass="control-width-40 clearable" cssStyle="width: 152px; height: 26px" ></s:select>
				 </td>
				 </tr>
				 <tr>
				 <td class="mtd">
					&nbsp;职位:&nbsp;
			 </td><td>
                	<s:select list="#{'':'-请先选择部门-'}" name="postId" id="postSelector" theme="simple" cssClass="control-width-40 clearable input-control" cssStyle="width: 152px; height: 26px"></s:select>
				</td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <div>
                            <input type="button" id="btnCloseSelector" value="提交" class="o-btn">
                            &nbsp;&nbsp;
                            <input type="button" name="name" id="cancelAddGoodsInfoButton" class="dialogFormCloseButton o-btn"
                                dialogform="#dialog-form" value="取消" />
                        </div>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
            </table>
        </div>
    </div> 
    <!-- 弹出层结束 -->
    <div id="addGoodsCategoryTab" title="添加" class="ui-assistantTab" style="display: none;">
        <table width="100%" class="tb tb2">
            <tbody>
                <tr>
                    <td class="mtd">
                        类型名称:
                    </td>
                    <td>
                        <input class="control" type="text" name="name" value="" />
                    </td>
                    <td width="20">
                    </td>
                </tr>
            </tbody>
            <tr>
                <td class="mtd">
                    &nbsp;
                </td>
                <td>
                    <input type="button" name="name" value="添加" class="o-btn"/>
                    <input type="button" name="name" id="cancelAddGoodsCategoryButton" value="取消" class="o-btn"/>
                </td>
                <td>
                </td>
            </tr>
        </table>
    </div>
</div>
</html>
